if(WScript.FullName.toLowerCase().indexOf("wscript") >= 0)
{
	WScript.echo("Please use cscript.exe scripting host to run this script.");
	WScript.quit();
}

WScript.echo("Press Ctrl+C to exit...");

var oshSource = null;

var oshClient = new ActiveXObject("OSH.Client");
WScript.ConnectObject(oshClient, "oshClient_");

oshClient.Connect("");


WScript.sleep(60 * 60 * 1000);
WScript.quit();


function oshClient_OnConnect(sourceName)
{
	WScript.echo("OnConnected(Source name: " + sourceName + ")");

	oshSource = new ActiveXObject("OSH.Source");
	WScript.ConnectObject(oshSource, "oshSource_");

	oshSource.Open(sourceName);
}

function oshClient_OnDisconnect()
{
	WScript.echo("OnDisconnect()");

	WScript.DisconnectObject(oshSource);
	oshSource.Close();
	oshSource = null;
}


function oshSource_OnShow(bitmap)
{
	WScript.echo("OnShow(Bitmap: " + formatTime(bitmap.Created) + 
		" at 0x" + bitmap.BitmapInfo.toString(16).toUpperCase() + ")");

	bitmap.Close();
	bitmap = null;
}

function oshSource_OnHide()
{
	WScript.echo("OnHide()");
}

function oshSource_OnRefresh(bitmap)
{
	WScript.echo("OnRefresh(Bitmap: " + formatTime(bitmap.Created) + 
		" at 0x" + bitmap.BitmapInfo.toString(16).toUpperCase() + ")");

	bitmap.Close();
	bitmap = null;
}

function formatTime(date)
{
	var d = new Date(date);
	d = new Date(Date.UTC(d.getYear(), d.getMonth(), d.getDay(),
		d.getHours(), d.getMinutes(), d.getSeconds(), d.getMilliseconds()));
	return d.toLocaleString() + " " + d.getMilliseconds();
}




